package com.ruoyi.supplier.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.supplier.mapper.TbProductTypeMapper;
import com.ruoyi.supplier.domain.TbProductType;
import com.ruoyi.supplier.service.ITbProductTypeService;

/**
 * 商品分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-02-20
 */
@Service
public class TbProductTypeServiceImpl implements ITbProductTypeService 
{
    @Autowired
    private TbProductTypeMapper tbProductTypeMapper;

    /**
     * 查询商品分类
     * 
     * @param id 商品分类ID
     * @return 商品分类
     */
    @Override
    public TbProductType selectTbProductTypeById(Long id)
    {
        return tbProductTypeMapper.selectTbProductTypeById(id);
    }

    /**
     * 查询商品分类列表
     * 
     * @param tbProductType 商品分类
     * @return 商品分类
     */
    @Override
    public List<TbProductType> selectTbProductTypeList(TbProductType tbProductType)
    {
        return tbProductTypeMapper.selectTbProductTypeList(tbProductType);
    }

    /**
     * 新增商品分类
     * 
     * @param tbProductType 商品分类
     * @return 结果
     */
    @Override
    public int insertTbProductType(TbProductType tbProductType)
    {
        tbProductType.setCreateTime(DateUtils.getNowDate());
        tbProductType.setCreateBy(SecurityUtils.getUsername());
        return tbProductTypeMapper.insertTbProductType(tbProductType);
    }

    /**
     * 修改商品分类
     * 
     * @param tbProductType 商品分类
     * @return 结果
     */
    @Override
    public int updateTbProductType(TbProductType tbProductType)
    {
        tbProductType.setUpdateTime(DateUtils.getNowDate());
        tbProductType.setUpdateBy(SecurityUtils.getUsername());
        return tbProductTypeMapper.updateTbProductType(tbProductType);
    }

    /**
     * 批量删除商品分类
     * 
     * @param ids 需要删除的商品分类ID
     * @return 结果
     */
    @Override
    public int deleteTbProductTypeByIds(Long[] ids)
    {
        return tbProductTypeMapper.deleteTbProductTypeByIds(ids);
    }

    /**
     * 删除商品分类信息
     * 
     * @param id 商品分类ID
     * @return 结果
     */
    @Override
    public int deleteTbProductTypeById(Long id)
    {
        return tbProductTypeMapper.deleteTbProductTypeById(id);
    }
}
